# -*- coding: utf-8 -*-
# @Time : 2025/1/23 15:56
# @Author : debbyszhang
# @File : login_page.py
# @desc :
from playwright.sync_api import Page

from config import settings
from libs.base_page import BasePage


class LoginPage(BasePage):
    def __init__(self, page: Page):
        super().__init__(page)
        self.url = settings.BASE_URL + "/login"
        self.username_input = "请输入用户名"
        self.password_input = "请输入密码"
        self.login_button = "登录"

    def login(self, username: str, password: str):
        """执行登录操作"""
        self.open(self.url)
        self.screenshot(path="./screenshots/login.png")

        self.click_fill(self.username_input, username)
        self.click_fill(self.password_input, password)
        self.screenshot(path="./screenshots/login_info.png")

        self.click(self.login_button)
        self.screenshot(path="./screenshots/after_login.png")
